import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput;
import com.sun.xml.internal.xsom.XSUnionSimpleType;

/**
 * @author 许喜朝
 */
public class TemplateMethodTest {
    public static void main(String[] args) {
        MySql mySql = new MySql();
        mySql.operation();
        Oracle redis = new Oracle();
        redis.operation();
    }
}
abstract class AbstractClass{
    public void operation(){
//        不同部分由子类实现
        templateMethod();
//        提取相同部分直接实现
        System.out.println("建立连接");
        System.out.println("执行sql");
        System.out.println("关闭连接");

    }
    abstract protected void templateMethod();
}
//mysql
class MySql extends AbstractClass{
    @Override
    protected void templateMethod() {
        System.out.println("mysql驱动");
    }
}
//oracle
class Oracle extends AbstractClass{

    @Override
    protected void templateMethod() {
        System.out.println("Orecle驱动程序");
    }
}
